home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-09 | 4.7 KB | 218 lines | [TEXT/MPS ] |
- { Implementation of OneDialog }
-
-
- TYPE
- TwoIntegers = RECORD CASE INTEGER OF
- 1: ( both : LONGINT );
- 2: ( first, second : INTEGER );
- END;
-
-
- VAR
- StandardScroll : Handle; {the old scroll CDEF proc}
- SpecialScroll : Ptr; {the new scroll CDEF proc}
-
-
- PROCEDURE DrawLine(aDialog: DialogPtr; itemNo: INTEGER);
- VAR
- itemType : INTEGER;
- itemHdl : Handle;
- itemRect : Rect;
- BEGIN
- GetDItem(TheDialog, itemNo, itemType, itemHdl, itemRect);
- FillRect(itemRect, gray)
- END;
-
-
-
- PROCEDURE SetIHandle(itemNo: INTEGER; hand: Handle);
- VAR
- itemType : INTEGER;
- itemHdl : Handle;
- itemRect : Rect;
- BEGIN
- GetDItem(TheDialog, itemNo, ItemType, ItemHdl, ItemRect);
- ItemHdl := hand;
- SetDItem(TheDialog, itemNo, ItemType, ItemHdl, ItemRect);
- END;
-
-
-
- FUNCTION NewScrollControl(varCode: INTEGER;
- theControl: ControlHandle;
- message: INTEGER;
- param: LONGINT): LONGINT;
- VAR
- moveAmounts : TwoIntegers;
- delta : INTEGER;
- value : INTEGER;
- ticksNow : LONGINT;
-
- FUNCTION CallOld(varCode: INTEGER;
- theControl: ControlHandle;
- message: INTEGER;
- param: LONGINT;
- proc: HANDLE): LONGINT;
- INLINE $205F, $2050, $4E90;
-
- BEGIN
- IF message = autoTrack THEN
- BEGIN
- moveAmounts.both := GetCRefCon(theControl);
- CASE param OF
- inUpButton: delta := - moveAmounts.first;
- inPageUp: delta := - moveAmounts.second;
- inPageDown: delta := moveAmounts.second;
- inDownButton: delta := moveAmounts.first;
- OTHERWISE delta := 0
- END;
- value := GetCtlValue(theControl);
- IF ((delta < 0) AND (value > GetCtlMin(theControl))) OR
- ((delta > 0) AND (value < GetCtlMax(theControl))) THEN
- BEGIN
- SetCtlValue(theControl, value+delta);
- Delay(5, ticksNow)
- END;
- NewScrollControl := 0
- END
- ELSE
- BEGIN
- LoadResource(StandardScroll);
- HLock(StandardScroll);
- NewScrollControl :=
- CallOld(varCode, theControl, message, param, StandardScroll);
- HUnLock(StandardScroll)
- END
- END;
-
-
- PROCEDURE FixScrollbar(itemNo: INTEGER;
- arrowAmount,pageAmount: INTEGER);
- VAR
- itemType : INTEGER;
- itemHdl : Handle;
- itemRect : Rect;
- itemCtrl : ControlHandle;
- refcon : TwoIntegers;
- BEGIN
- GetDItem(TheDialog, itemNo, ItemType, ItemHdl, ItemRect);
- itemCtrl := ControlHandle(itemHdl);
-
- refcon.first := arrowAmount;
- refcon.second := pageAmount;
- SetCRefCon(itemCtrl, refcon.both);
-
- HLock(itemHdl);
- WITH itemCtrl^^ DO
- BEGIN
- StandardScroll := contrlDefProc;
- SpecialScroll := Ptr(@NewScrollControl);
- contrlDefProc := @SpecialScroll;
- END;
- HUnLock(itemHdl);
- SetCtlAction(itemCtrl, ProcPtr(-1));
- END;
-
-
-
- PROCEDURE FixUserLine(itemNo: INTEGER);
- BEGIN
- SetIHandle(itemNo, Handle(@DrawLine));
- END;
-
-
-
- PROCEDURE ActivateItem(itemNo: INTEGER);
- VAR
- itemType : INTEGER;
- itemHdl : Handle;
- itemRect : Rect;
- itemCtrl : ControlHandle;
- BEGIN
- GetDItem(TheDialog, itemNo, ItemType, ItemHdl, ItemRect);
- itemCtrl := ControlHandle(itemHdl);
- HiliteControl(itemCtrl, 0);
- END;
-
-
-
- PROCEDURE DeactivateItem(itemNo: INTEGER);
- VAR
- itemType : INTEGER;
- itemHdl : Handle;
- itemRect : Rect;
- itemCtrl : ControlHandle;
- BEGIN
- GetDItem(TheDialog, itemNo, ItemType, ItemHdl, ItemRect);
- itemCtrl := ControlHandle(itemHdl);
- HiliteControl(itemCtrl, 255);
- END;
-
-
-
- PROCEDURE Message(text:Str255; itemNo:INTEGER);
- VAR
- itemType : INTEGER;
- itemHdl : Handle;
- itemRect : Rect;
- BEGIN
- IF TheDialog <> NIL THEN BEGIN
- GetDItem(TheDialog, itemNo, itemType, itemHdl, itemRect);
- SetIText(itemHdl, text)
- END;
- END;
-
-
-
- PROCEDURE DetermineValue(VAR variable: INTEGER;
- itemNo: INTEGER);
- VAR
- itemType : INTEGER;
- itemHdl : Handle;
- itemRect : Rect;
- itemCtrl : ControlHandle;
- BEGIN
- GetDItem(TheDialog, itemNo, itemType, itemHdl, itemRect);
- itemCtrl := ControlHandle(itemHdl);
- variable := GetCtlValue(itemCtrl)
- END;
-
-
-
- PROCEDURE SetValue(value: INTEGER; VAR variable: INTEGER;
- itemNo: INTEGER);
- VAR
- itemType : INTEGER;
- itemHdl : Handle;
- itemRect : Rect;
- itemCtrl : ControlHandle;
- BEGIN
- GetDItem(TheDialog, itemNo, itemType, itemHdl, itemRect);
- itemCtrl := ControlHandle(itemHdl);
- SetCtlValue(itemCtrl, value);
- variable := value
- END;
-
-
-
- PROCEDURE ChangeState(state:BOOLEAN;
- VAR variable:BOOLEAN;
- itemNo:INTEGER);
- VAR
- itemType : INTEGER;
- itemHdl : Handle;
- itemRect : Rect;
- itemCtrl : ControlHandle;
- BEGIN
- GetDItem(TheDialog, itemNo, itemType, itemHdl, itemRect);
- itemCtrl := ControlHandle(itemHdl);
-
- IF state THEN
- SetCtlValue(itemCtrl, 1)
- ELSE
- SetCtlValue(itemCtrl, 0);
-
- variable := state;
- END;
-
-